﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class LevelBMFill : BasePage
{
    string _timeID = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Count > 0)
        {

            _timeID = Request.Params["TimeID"].Trim();
            if (!Page.IsPostBack)
            {
                DataTable dt = Exam.ExamRank_GetRankName(_timeID);
                if (dt.Rows.Count > 0)
                {
                    BSUtility.BindListControl(List_level, dt, "EmRankName", "EmRankName");
                }

            }
        }
        else
        {
            Response.Redirect(BSUtility.mainUrl + "default.aspx");
        }

        
    }

    protected override void Page_LoadAlways()
    {
        base.Page_LoadAlways();
        //判断是否超时
        if (Exam.ExamTime_IsTimeOut(_timeID))
        {
            #region 如果已有报名信息
            DataTable dt_apply = Exam.ApplyInfo_GetInfo(IDCard, _timeID);
            if (dt_apply.Rows.Count > 0)
            {
                DataRow dr_apply = dt_apply.Rows[0];
                string orderId = dr_apply["OrderID"].ToString();
                string sOrderId = security.EncryptQueryString(orderId);
                int applyState = int.Parse(dr_apply["ApplyState"].ToString());
                if (applyState == 1)
                {
                    //如果正在报名中则不做任何修改
                }
                else if (applyState == 2)
                {
                    Response.Redirect("BM5.aspx?orderID=" + sOrderId);
                }
            }
            #endregion
        }
        else
            Response.Redirect(BSUtility.mainUrl + "Default.aspx");
    }

 
    protected void SInfoBtn_Insert_Click(object sender, EventArgs e)
    {
        string emRankName = List_level.Text;
        if (!Exam.BMInfo_Save(IDCard, _timeID, emRankName))
        {
            //提示信息
        }
        else
        {

            Response.Redirect("BMInfoConfirm.aspx?TimeID=" + _timeID);
            //或者考试，次数 或者 报名号 ，身份证号
         
        }
        
    }

}